<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

		
	<p:tabView id = "tab">
		<p:tab title="Dados Pessoais">
			<h:panelGroup id="group_verifica_cpf" rendered="#{!fornecedorManager.isCnpjValido}">
				<h:panelGrid columns="2">
					<h:outputText value="CNPJ" />
					<h:outputText value="" />
					<p:inputMask id="cnpj" mask="99.999.999/9999-99" value="#{fornecedorManager.fornecedor.cnpj}" required="true" label="CNPJ" converter="cnpjConverter" />
					<p:commandButton value="Verificar" id="verificar_cnpj" ajax="false" action="#{fornecedorManager.validateCnpj}" />
				</h:panelGrid>
			</h:panelGroup>
			
			<h:panelGroup  rendered="#{fornecedorManager.isCnpjValido}">
				<h:panelGrid columns="2" cellpadding="0" cellspacing="0">
					<h:outputText value="CNPJ" />
					<h:outputText value="Razão Social" />
					<p:inputMask mask="99.999.999/9999-99" id="cnpj_read" value="#{fornecedorManager.fornecedor.cnpj}" required="true" label="CNPJ" converter="cpfConverter" maxlength="14" readonly="true" disabled="#{fornecedorManager.isTelaAtendimento}"/>
					<p:inputText value="#{fornecedorManager.fornecedor.razaoSocial}" id="nome" label="Nome" required="true" maxlength="255" style="width:400px;" disabled="#{fornecedorManager.isTelaAtendimento}">
						<f:validateLength maximum="255" minimum="2"/>
					</p:inputText>
					
					<h:outputText value="Nome Fantasia" />
					<h:outputText value="Contato da Empresa" />
					
					<h:inputText value="#{fornecedorManager.fornecedor.nomeFantasia}" />
					<h:inputText value="#{fornecedorManager.fornecedor.contato}" />
					
				</h:panelGrid>
				
				<br />
				<p:panel id="endereco"  header="Endereço">
					<ui:include src="/geral/paginas/geral/formEndereco.xhtml" />
				</p:panel>
				
				<br />
				<p:panel id="contato" header="Contato">
					<ui:include src="/geral/paginas/geral/formTelefone.xhtml" />
				</p:panel>
			</h:panelGroup>
		</p:tab>
	</p:tabView>
	
	<p:commandButton action="#{fornecedorManager.save}" value="Salvar" rendered="#{fornecedorManager.isCnpjValido and fornecedorManager.fornecedor.id == null}" update="form" />
	<p:commandButton action="#{fornecedorManager.update}" value="Salvar" rendered="#{fornecedorManager.isCnpjValido and fornecedorManager.fornecedor.id != null}" update="form"  />
	
	
</html>